package com.bw.ppjokeplay.mvvm.view.sofa

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.viewpager.widget.ViewPager
import com.bw.ppjokeplay.BR
import com.bw.ppjokeplay.R
import com.bw.ppjokeplay.adapter.MyvpAdapter
import com.bw.ppjokeplay.commen.mvvm.view.BaseFragment
import com.bw.ppjokeplay.mvvm.view.sofa.fragment.ImgFragment
import com.bw.ppjokeplay.mvvm.view.sofa.fragment.TxtFragment
import com.bw.ppjokeplay.mvvm.view.sofa.fragment.VideoFragment
import com.bw.ppjokeplay.mvvm.viewmodel.sofa.SofaViewModel
import com.flyco.tablayout.SlidingTabLayout

/**
 * @author Lishaohe
 * @description:
 * @date :2021/11/10 0010 下午 2:05
 *
 */
class SofaFragment: Fragment() {
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val inflate = inflater.inflate(R.layout.fragment_sofa, container, false)
        val tab = inflate.findViewById<SlidingTabLayout>(R.id.tab)
        val VP = inflate.findViewById<ViewPager>(R.id.VP)
        val string = ArrayList<String>()
        val fragment = ArrayList<Fragment>()
        string.add("图片")
        string.add("视频")
        string.add("文本")
        fragment.add(ImgFragment())
        fragment.add(VideoFragment())
        fragment.add(TxtFragment())

        val myvpAdapter = MyvpAdapter(childFragmentManager)
        myvpAdapter!!.fragment=fragment
        myvpAdapter!!.string=string
        VP.adapter = myvpAdapter
        tab.setViewPager(VP)
        return inflate
    }

}